const { merge } = require('webpack-merge')
const common = require('./webpack.common')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = merge(common, {
  mode: 'production',
  // source-map 模式
  devtool: 'none',
  plugins: [
    // 清除 dist 目录
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin({
      patterns: [
        { from: 'public', to: '' }
      ]
    })
  ],
  optimization: {
    // 压缩输出结果
    // minimize: false,
    splitChunks: {
      // 自动提取所有公共模块到单独 bundle
      chunks: 'all',
      maxSize: 100000
    }
  }
})
